<template>
  <el-dialog :title="'记录'+'（'+form.orderNo+'）'" :visible.sync="dialogVisible" width="60%">
    <el-table :data="list" max-height="500" v-loading="loading">
      <el-table-column type="index" label="序号" align="center"/>
      <el-table-column prop="operTime" label="操作时间" align="center"/>
      <el-table-column prop="operator" label="操作人" align="center"/>
      <el-table-column prop="title" label="主题" align="center"/>
      <el-table-column prop="content" label="内容" align="center"/>
      <el-table-column prop="fileUrl" label="附件" align="center">
        <template slot-scope="scope">
          <el-button type="text" v-if="scope.row.fileUrl" @click="downloadFIle(scope.row.fileUrl)">下载</el-button>
          <div v-else>-</div>
        </template>
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible=false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>

import {listSaleOrderLog} from "@/api/imsMng";

export default {
  data() {
    return {
      dialogVisible: false,
      loading: true,
      form: {},
      list: []
    }
  },
  methods: {
    show(form) {
      this.dialogVisible = true
      this.resetForm('form')
      this.form.orderNo = form.orderNo
      this.list = []
      this.loading = true
      listSaleOrderLog({orderId:form.id,pageSize:-1}).then(res => {
        this.list = res.rows
      }).finally(e => {
        this.loading = false
      })
    },
    downloadFIle(fileUrl) {
      window.open(fileUrl)
    }
  }
}
</script>
